#include <stdio.h>
#include <stdlib.h>

typedef int DataType;
typedef struct node
{
    DataType data;
    struct node *next;
} linkStack;

// 初始化
linkStack *init()
{
    linkStack *stack = (linkStack *)malloc(sizeof(linkStack));
    stack->next = NULL;
    return stack;
}
// 判断栈空
int isEmpty(linkStack *s)
{
    if (s->next == NULL)
    {
        return 1;
    }
    return 0;
}
// 进栈
void Push(linkStack *stack, DataType x)
{
    linkStack *newNode = (linkStack *)malloc(sizeof(linkStack));
    newNode->data = x;
    newNode->next = (stack)->next;
    (stack)->next = newNode;
}
// 出栈
int pop(linkStack *stack)
{
    if (!isEmpty(stack))
    {
        linkStack *removeNode = stack->next;
        stack->next = removeNode->next;
        free(removeNode);
        return 1;
    }
    return 0;
}

// 取栈顶元素
DataType *getTop(linkStack *stack)
{
    if (isEmpty(stack))
    {
        return NULL;
    }
    return &(stack->next->data);
}

int main()
{
    linkStack *s = init();
    Push(s, 1);
    printf("判断栈空:%d\n", isEmpty(s));
    return 0;
}